//
//  AViewController.m
//  页面之间传值
//
//  Created by MAC on 2018/8/24.
//  Copyright © 2018年 MAC. All rights reserved.
//

#import "AViewController.h"
#import "A-2-ViewController.h"

@interface AViewController ()
@property (nonatomic,strong) UIButton *btn;
@property (nonatomic,strong) UITextField *textF;
@end

@implementation AViewController
- (UITextField *)textF
{
    if (_textF == nil) {
        _textF = [[UITextField alloc]initWithFrame:CGRectMake((self.view.frame.size.width-200)/2, 100, 200, 40)];
        _textF.textColor = [UIColor blackColor];
        _textF.borderStyle = UITextBorderStyleLine;
    }
    return _textF;
}

- (UIButton *)btn
{
    if (_btn == nil) {
        _btn = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn.backgroundColor = [UIColor redColor];
        _btn.frame = CGRectMake((self.view.frame.size.width-200)/2, _textF.frame.origin.y+_textF.frame.size.height+40, 200, 40);
        [_btn setTitle:@"跳转页面二" forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //点击事件
        [_btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.textF];
    [self.view addSubview:self.btn];
}

//button点击事件 -- 跳转到B页面
- (void)btnClick
{
    A_2_ViewController *a_2_VC = [[A_2_ViewController alloc]init];
    
    //属性传值 - 输入要传的值
    a_2_VC.str = self.textF.text;
    a_2_VC.view.backgroundColor = [UIColor whiteColor];
    [self presentViewController:a_2_VC animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
